<?php

/**
 * UploadedMaterial form.
 *
 * @package    Amman to London
 * @subpackage form
 * @author     Adel Abu-Saif <adeljas@msn.com>
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class UploadedMaterialForm extends BaseUploadedMaterialForm {

    public function configure() {
        $this->widgetSchema['local_file'] = new sfWidgetFormInputFile();
        $this->validatorSchema['local_file'] = new sfValidatorFile(
                        array(
                            'path' => sfConfig::get('sf_upload_dir') . '/uploaded_material/'
                            , 'required' => false
                        )
        );

        $this->validatorSchema['url'] = new sfValidatorUrl(array('required' => false));

        $params = sfContext::getInstance()->getRequest()->getPostParameters();
        if (isset($params['upload_type']) && $params['upload_type'] == 'file')
            $this->validatorSchema['local_file']->setOption('required', true);
        if (isset($params['upload_type']) && $params['upload_type'] == 'url')
            $this->validatorSchema['url']->setOption('required', true);
    }

}
